1. Field of the Invention
The present invention relates to a data communication device, a communication control method, and a program. More particularly, the present invention is concerned with a data communication device, a communication control method, and a program that perform serial communication of an asynchronous type.
2. Description of the Related Art
As one of communication methods of communicating data through serial communication, an asynchronous method is known. Referring to FIGS. 1A and 1B, serial data communication conformable to the asynchronous method will be outlined below. FIG. 1A shows an example of a communication topology for serial data communication conformable to the asynchronous method, and FIG. 1B shows an example of a data structure for communication data.
For example, serial data communication is performed between a communicating section (master) 10 and a communicating section (slave) 20 shown in FIG. 1A. Each of the communicating section (master) 10 and communicating section (slave) 20 has a transmitting/receiving terminal, and performs data transmission or data reception by way of the transmitting/receiving terminal.
Communication data to be transferred between the communicating section (master) 10 and communicating section (slave) 20 is, as shown in FIG. 1B, structured to have data, which is an object of transmission, sandwiched between a start bit and a stop bit. More particularly, for example, the start bit is one bit long, the data is 8 bits long, and the stop bit is one bit long.
The thus structured communication data is produced on a transmitting side and outputted to a receiving side. The communication data having the data sandwiched in units of one byte (8 bits) between the start bit and stop bit is produced and transmitted.
The communication data shown in FIG. 1B is successively transferred according to an amount of data forming transmission data. For example, when data of 16 bytes long is transmitted, sixteen communication data items each of which is identical to the one shown in FIG. 1B are produced and transmitted at predetermined intervals. The data receiving side recognizes data, which is sandwiched between a start bit and a stop bit, as data that is an object of reception. For example, the start bit is defined as one bit of 0 representing a low level and the stop bit is defined as one bit of 1 representing a high level. The receiving side discriminates the start and stop bits from the data according to this rule, and acquires and analyzes the intermediate data.
The example shown in FIG. 1B is an example in which data of 8 bits long is sandwiched between the start and stop bits. The data sandwiched between the start and stop bits is not limited to the data of 8 bits long. For example, a parity bit for error correction may be appended to the 8-bit data.
For discriminating the start and stop bits from data on the data receiving side, information on a bit width is necessary. Both the transmitting and receiving sides are requested to share the same understanding of the bit width. The data receiving side uses a clock to detect the bit width, and acquires the data according to the foregoing technique.
The width of one bit may be set to various values. If the bit width is set to a short time, a transmission speed is raised. The data receiving side recognizes a data transmission speed by measuring the bit width of the start bit. More particularly, the number of clock pulses of a clock signal, which is employed on the receiving side, equivalent to the bit width of the start bit is counted.
The transmission speed in serial data communication is often expressed with a baud rate defined as the number of bits per second (bps or bits per second). The data transmitting side and data receiving side are requested to treat data at the same baud rate. Therefore, a preset baud rate may be utilized for serial communication. Otherwise, the transmitting side checks the baud rate employed on the receiving side, produces transmission data at the same baud rate as the baud rate employed on the receiving side, and then transmits the data.
The transmitting side checks the baud rate employed on the receiving side by performing processing described below. To begin with, the transmitting side executes test transmission at multiple baud rates, and checks whether a response is returned from the receiving side. The transmitting side recognizes a baud rate, at which a response is returned from the receiving side, as a baud rate usable on the receiving side. The transmitting side performs real transmission of data at the baud rate. If this kind of preprocessing is carried out, both the data transmitting side and data receiving side can treat data at the same baud rate.
The data receiving side identifies the number of clock pulses equivalent to the bit width of the start bit, and uses the number of clock pulses as a reference to check whether each of the bits of data is 1 or 0. For accurate transmission or reception of data, it is necessary to accurately measure the bit width of the start bit.
However, as shown in FIG. 1B, the start bit and data are adjoined to each other, and may not be clearly discriminated from each other. For example, when the start bit is defined as one bit of 0 representing a low level, if the first bit of the succeeding data is the same as the start bit of 0 representing the low level, it becomes hard to identify the border between the start bit and data. In this case, it is hard to measure the bit width.
As a related art in which a technique for solving the foregoing problem is disclosed, there is patent document 1 (JP-A-2007-259094). According to the patent document 1, a start bit is alternating data of two bits long, that is, includes two bits of 10 or 01. Owing to the data length, the receiving side can reliably detect both the leading and trailing edges of a pulse representing a bit contained in the start bit, and can detect the bit width highly precisely.
According to patent document 2(JP-A-2001-168853), a special command for measurement of a bit width is prepared. A receiving side uses the command to measure the bit width of a start bit.
Owing to the constitutions of the related arts, measurement of a bit width can be highly precisely achieved. However, the technique disclosed in the patent document 1 uses two bits for the start bit. The occupation ratio of the start bit to transfer data gets higher. As a result, a data transmission rate decreases.
According to the technique disclosed in the patent document 2, the special command has to be transmitted and receive in advance for the purpose of measurement. This poses a problem in that processing efficiency is degraded. In addition, if the data transmitting side changes transmission speeds, that is, baud rates, every time the necessity of speed changing processing occurs, the special command has to be transmitted for measurement. In a configuration in which changing transmission speeds arises, the processing efficiency is markedly degraded.
The patent document 1 refers to JP-A-2007-259094, and the patent document 2 refers to JP-A-2001-168853.